package com.ibm.psbc.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.ibm.psbc.cloud.config.TestConfig;

@RestController
public class EchoController {
	@Autowired TestConfig config;
    @RequestMapping(value = "/echo/{string}")
    @SentinelResource(value="echo", fallback = "echoFallBack")
    public String echo(@PathVariable String string) {
    	System.out.println("echo from:" + this);
    	try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        return "Hello Nacos Discovery " + string;
    }
    @RequestMapping(value = "/001/echo/{string}")
    public String echo1(@PathVariable String string) {
    	System.out.println("echo001 from:" + this);
    	try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        return "Hello Nacos Discovery " + string;
    }
    
    public String echoFallBack(String s) {
    	return "Fallback";
    }

}